namespace CIS.Customer
{
    using CISLib;
    using CISLib.EncryptClasses;
    using System;
    using System.Configuration;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class CustomerProfile : Page
    {
        protected Label lblAllergy;
        protected Label lblAllergyLabel;
        protected Label lblASBEventInfo;
        protected Label lblASBReceptionInfo;
        protected Label lblASBResource;
        protected Label lblASBResourceInfo;
        protected Label lblASBTrainingInfo;
        protected Label lblBasicInfo;
        protected Label lblBrandPre;
        protected Label lblBrandPreLabel;
        protected Label lblBusinessInfo;
        protected Label lblClothingSituationLabel;
        protected Label lblCompetitorEventInfo;
        protected Label lblCompetitorMeetingInfo;
        protected Label lblContractInfo;
        protected Label lblCoupon;
        protected Label lblCouponLabel;
        protected Label lblCustomerBirth;
        protected Label lblCustomerBirthLabel;
        protected Label lblCustomerBirthPlace;
        protected Label lblCustomerBirthPlaceLabel;
        protected Label lblCustomerBloodType;
        protected Label lblCustomerBloodTypeLabel;
        protected Label lblCustomerCompany;
        protected Label lblCustomerCompanyLabel;
        protected Label lblCustomerDefine;
        protected Label lblCustomerDefineLabel;
        protected Label lblCustomerDept;
        protected Label lblCustomerDeptLabel;
        protected Label lblCustomerEmail;
        protected Label lblCustomerEmailLabel;
        protected Label lblCustomerEventInfo;
        protected Label lblCustomerGender;
        protected Label lblCustomerGenderLabel;
        protected Label lblCustomerHeight;
        protected Label lblCustomerHeightLabel;
        protected Label lblCustomerHomeAdd;
        protected Label lblCustomerHomeAddLabel;
        protected Label lblCustomerHomeTel;
        protected Label lblCustomerHomeTelLabel;
        protected Label lblCustomerLevel;
        protected Label lblCustomerLevelLabel;
        protected Label lblCustomerMarriage;
        protected Label lblCustomerMarriageLabel;
        protected Label lblCustomerMobile;
        protected Label lblCustomerMobileLabel;
        protected Label lblCustomerName;
        protected Label lblCustomerNameLabel;
        protected Label lblCustomerProfileName;
        protected Label lblCustomerProfileText;
        protected Label lblCustomerRelocationAdd;
        protected Label lblCustomerRelocationAddLabel;
        protected Label lblCustomerSpcHobbies;
        protected Label lblCustomerSpcHobbiesLabel;
        protected Label lblCustomerTitle;
        protected Label lblCustomerTitleLabel;
        protected Label lblCustomerWeight;
        protected Label lblCustomerWeightLabel;
        protected Label lblEditor;
        protected Label lblEditorText;
        protected Label lblEVMeetingInfo;
        protected Label lblEyesight;
        protected Label lblEyesightLabel;
        protected Label lblHealthCostumeInfo;
        protected Label lblHealthInfo;
        protected Label lblHealthState;
        protected Label lblHealthStateLabel;
        protected Label lblHip;
        protected Label lblHipLabel;
        protected Label lblMajorOperation;
        protected Label lblMajorOperationLabel;
        protected Label lblNeck;
        protected Label lblNeckLabel;
        protected Label lblOther;
        protected Label lblOtherLabel;
        protected Label lblPaperInfo;
        protected Label lblPaperName;
        protected Label lblPaperNameLabel;
        protected Label lblPersonalInfo;
        protected Label lblPicInfo;
        protected Label lblPreferenceDescLabel;
        protected Label lblPreferenceInfo;
        protected Label lblPreferenceLevelLabel;
        protected Label lblPreferenceTypeLabel;
        protected Label lblProduct;
        protected Label lblProductLabel;
        protected Label lblResponsibleStaffInfo;
        protected Label lblShoes;
        protected Label lblShoesLabel;
        protected Label lblSpecialDisease;
        protected Label lblSpecialDiseaseLabel;
        protected Label lblStudyDateBegin;
        protected Label lblStudyInfo;
        protected Label lblTranSportTool;
        protected Label lblTranSportToolLabel;
        protected Label lblTravelInfo;
        protected Label lblVisitingAbroadInfo;
        protected Label lblWorkInfo;
        protected Repeater rptASBEvent;
        protected Repeater rptASBReception;
        protected Repeater rptASBResource;
        protected Repeater rptASBTraining;
        protected Repeater rptCompetitorEvent;
        protected Repeater rptCompetitorMeeting;
        protected Repeater rptContract;
        protected Repeater rptCustomerEvent;
        protected Repeater rptEVMeeting;
        protected Repeater rptImage;
        protected Repeater rptPaperName;
        protected Repeater rptPreference;
        protected Repeater rptResponsibleStaff;
        protected Repeater rptStudy;
        protected Repeater rptTravel;
        protected Repeater rptVisitingAbroad;
        protected Repeater rptWork;

        protected string AddStrPrefix(object obj, string strPre)
        {
            if (obj.ToString() == string.Empty)
            {
                return "";
            }
            string language = this.Session["language"].ToString();
            string path = base.Server.MapPath("~/CIS/LanguageConfig.xml");
            return (ManageSystemConfig.GetSystemSetLanguage("CustomerInfoStudyPage", strPre, language, path) + obj.ToString());
        }

        protected string DecryptString(object obj)
        {
            return ManageOther.DecodeWithBytes(obj.ToString());
        }

        protected string DecryptString2(object obj)
        {
            DESEncrypt mydes = new DESEncrypt();
            return mydes.DecryptString(obj.ToString());
        }

        protected string DecryptUnicodeString(object obj)
        {
            return ManageOther.DecodeWithBytes(obj.ToString());
        }

        protected string GetTrainSchool(object obj)
        {
            Guid[] CustomerSchoolId = ManageCustomer.GetCustomerSchoolIdAryViaCustomerTrainId((Guid) obj);
            string result = "";
            for (int i = 0; i < CustomerSchoolId.Length; i++)
            {
                CustomerSchool school = ManageCustomerSchool.GetCustomerSchoolViaId(CustomerSchoolId[i]);
                result = result + school.SchoolName + " ";
            }
            return result;
        }

        protected string GetTrainType(object obj)
        {
            return ManageCustomerTrain.GetCustomerTrainViaId((Guid) obj).TrainName;
        }

        private void InitializeComponent()
        {
            base.Load += new EventHandler(this.Page_Load);
        }

        protected override void OnInit(EventArgs e)
        {
            this.InitializeComponent();
            base.OnInit(e);
        }

        private void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                Guid customerId = new Guid(base.Request.QueryString.Get("CustomerId").ToString());
                CustomerBasicInfo customerBasicInfo = ManageCustomer.GetCustomerBasicInfoViaId(customerId);
                this.lblCustomerProfileName.Text = customerBasicInfo.Name;
                this.lblEditor.Text = ManageUser.GetUserViaId(customerBasicInfo.UserId).LoginName;
                this.lblCustomerName.Text = customerBasicInfo.Name;
                this.lblCustomerGender.Text = customerBasicInfo.Gender;
                this.lblCustomerCompany.Text = ManageCompany.GetCompanyViaId(customerBasicInfo.CompanyId).CompanyName;
                this.lblCustomerDept.Text = customerBasicInfo.Depart;
                this.lblCustomerTitle.Text = customerBasicInfo.Title;
                this.lblCustomerLevel.Text = customerBasicInfo.Level.ToString();
                this.lblCustomerEmail.Text = customerBasicInfo.MailAdd;
                this.lblCustomerDefine.Text = ManageCustomerDef.GetDefViaId(customerBasicInfo.CustomerDefId).DefName;
                CustomerPersonalInfo customerPersonalInfo = ManageCustomer.GetCustomerPersonalInfoViaId(customerId);
                this.lblCustomerBirth.Text = customerPersonalInfo.BirthDate.ToString();
                this.lblCustomerMarriage.Text = customerPersonalInfo.MarriageDate.ToString();
                this.lblCustomerBirthPlace.Text = customerPersonalInfo.BirthPlace;
                this.lblCustomerHomeAdd.Text = customerPersonalInfo.FamilyAdd;
                this.lblCustomerRelocationAdd.Text = customerPersonalInfo.RelocationAdd;
                this.lblCustomerHomeTel.Text = customerPersonalInfo.PersonalTele;
                this.lblCustomerMobile.Text = customerPersonalInfo.Mobile;
                this.lblCustomerBloodType.Text = customerPersonalInfo.BloodType;
                this.lblCustomerWeight.Text = customerPersonalInfo.Weight;
                this.lblCustomerHeight.Text = customerPersonalInfo.Height;
                this.lblCustomerSpcHobbies.Text = customerPersonalInfo.SpecicalHobbies;
                this.rptStudy.DataSource = ManageCustomer.GetCustomerStudyExperienceInfo(customerId);
                this.rptStudy.DataBind();
                this.rptWork.DataSource = ManageCustomer.GetCustomerWorkExperienceInfo(customerId);
                this.rptWork.DataBind();
                this.rptPreference.DataSource = ManagePreference.GetCustomerPreferenceInfo(customerId);
                this.rptPreference.DataBind();
                CustomerHealth customerHealth = ManageCustomer.GetCustomerHealthViaId(customerId);
                this.lblHealthState.Text = customerHealth.HealthStatus.ToString();
                this.lblEyesight.Text = customerHealth.Eyesight.ToString();
                this.lblMajorOperation.Text = customerHealth.MajorOperation;
                this.lblSpecialDisease.Text = customerHealth.SpecialDisease;
                this.lblAllergy.Text = customerHealth.Allergy;
                CustomerCostumeInfo customerCostumeInfo = ManageCustomer.GetCustomerCostumeInfoViaId(customerId);
                this.lblNeck.Text = customerCostumeInfo.NeckMeasurement;
                this.lblShoes.Text = customerCostumeInfo.ShoesSize;
                this.lblHip.Text = customerCostumeInfo.HipMeasurement;
                this.lblBrandPre.Text = customerCostumeInfo.BrandPre;
                this.lblTranSportTool.Text = ManageCustomer.GetCustomerTravelInfoOfTranTool(customerId);
                this.rptTravel.DataSource = ManageCustomer.GetCustomerTravelInfo(customerId);
                this.rptTravel.DataBind();
                this.rptContract.DataSource = ManageCustomer.GetCustomerASBContractInfo(customerId);
                this.rptContract.DataBind();
                this.rptEVMeeting.DataSource = ManageCustomer.GetCustomerEVMeetingInfo(customerId);
                this.rptEVMeeting.DataBind();
                this.rptVisitingAbroad.DataSource = ManageCustomer.GetCustomerVisitingAbroadInfo(customerId);
                this.rptVisitingAbroad.DataBind();
                this.rptASBTraining.DataSource = ManageCustomer.GetCustomerTrainInfo(customerId);
                this.rptASBTraining.DataBind();
                this.rptASBEvent.DataSource = ManageCustomer.GetCustomerASBEventsInfo(customerId);
                this.rptASBEvent.DataBind();
                this.rptCustomerEvent.DataSource = ManageCustomer.GetCustomerEventsInfo(customerId);
                this.rptCustomerEvent.DataBind();
                this.rptASBResource.DataSource = ManageCustomer.GetCustomerRelationsInfo(customerId);
                this.rptASBResource.DataBind();
                this.rptResponsibleStaff.DataSource = ManageCustomer.GetCustomerResponsibleStaffInfo(customerId);
                this.rptResponsibleStaff.DataBind();
                this.rptASBReception.DataSource = ManageCustomer.GetCustomerASBReceptionInfo(customerId);
                this.rptASBReception.DataBind();
                this.rptCompetitorMeeting.DataSource = ManageCustomer.GetCustomerCompetitorMeetingInfo(customerId);
                this.rptCompetitorMeeting.DataBind();
                this.rptCompetitorEvent.DataSource = ManageCustomer.GetCustomerCompetitorEventsInfo(customerId);
                this.rptCompetitorEvent.DataBind();
                this.rptPaperName.DataSource = ManageCustomer.GetCustomerNewsPaperAryViaId(customerId);
                this.rptPaperName.DataBind();
                this.rptImage.DataSource = ManageCustomer.GetCustomerImageInfo(customerId);
                this.rptImage.DataBind();
            }
        }

        protected string SetDegreeStr(object obj)
        {
            switch (this.Session["language"].ToString())
            {
                case "cn":
                    return obj.ToString();
            }
            switch (((string) obj))
            {
                case "大专以下":
                    return "Below";

                case "大专":
                    return "College";

                case "本科":
                    return "Bachelor";

                case "硕士":
                    return "Master";

                case "博士":
                    return "doctor";

                case "MBA":
                    return "MBA";

                case "EMBA":
                    return "EMBA";

                case "DBA":
                    return "DBA";
            }
            return "";
        }

        protected string SetVenueLanguage(object obj)
        {
            string language = this.Session["language"].ToString();
            string strABVenue = obj.ToString();
            strABVenue = strABVenue.Substring(0, strABVenue.IndexOf("\0"));
            string[] strABVenueAry = strABVenue.Split(new char[] { ',' });
            string cnName = ConfigurationSettings.AppSettings["CountryCh"];
            string enName = ConfigurationSettings.AppSettings["CountryEn"];
            string[] cnAry = cnName.Split(new char[] { ',' });
            string[] enAry = enName.Split(new char[] { ',' });
            string strTmp = "";
            switch (language)
            {
                case "cn":
                    for (int i = 0; i < strABVenueAry.Length; i++)
                    {
                        for (int j = 0; j < enAry.Length; j++)
                        {
                            if (strABVenueAry[i] == enAry[j])
                            {
                                strTmp = strTmp + cnAry[j] + ",";
                            }
                        }
                    }
                    if (strTmp == "")
                    {
                        return strTmp;
                    }
                    return strTmp.Substring(0, strTmp.Length - 1);

                case "en":
                    return strABVenue;
            }
            return strTmp;
        }
    }
}

